# -*- codeing = utf-8 -*-
# @Time : 2021/3/4 17:30
# @Atuthor: 朱朱
# @File: 176正则练习4.py
# @Software: PyCharm
import re
# ip地址检测 0.0.0.0 ~ 255.255.255.255
ip = input('请输入ip地址:')
# #    0~9      10~99            100 ~ 199  200~209 210~219 220~229 230~239 240~249  250~255
# # \d:一位数   [1-9]\d:两位数   1\d{2}:1xx  2:00~255
x = re.fullmatch(r'((\d|[1-9]\d|1\d{2}|2([0-4]\d|5[0-5]))\.){3}(\d|[1-9]\d|1\d{2}|2([0-4]\d|5[0-5]))', ip)
print(x)


re1 = re.finditer(r'-?(0|[1-9]\d*)(\.\d+)?', '-90good87ni0ce19bye.52.')
re2 = re.finditer(r'-?(0|[1-9]\d*)(\.\d+)?', '-90good87ni0ce19bye')
for i in re1:
    print(i.group())


# 非捕获分组
x = re.findall(r'(?:-)?\d+(?:\.\d+)?', '-90good87ni0ce19bye')
print(x)